/********************************************/
//
// Company : HTHK
// Name    : UserOptions.java
// Function : Selection box of user account
// By       : Miranda Lin
// Date     : 11-Aug-2004 CRLOG 1347
/*********************************************/

package admin.options;

import com.ffpc.html.Options;

import java.util.ArrayList;
import java.sql.Connection;

import admin.*;
import admin.system.user.UserBean;
import admin.system.user.UserProcess;

public class UserOptions
  extends Options
{
  private String request_group;
  /**
   * Constructor
   */
  public UserOptions(String request_group)
  {
      this.request_group = request_group;
      this.load();
  }

  @Override
protected ArrayList createOptions(Connection con)
    throws Exception
  {
      ArrayList options = new ArrayList();
      UserBean user = UserProcess.createBean();
      user.setRequest_group(this.request_group);
      UserBean[] users = UserProcess.find(con,user);
      for (int i=0; i<users.length; i++)
      {
          Options.Option option
          = new Options.Option( users[i].getUser_id(),
                                users[i].getUser_name());
          options.add(i,option);
      }
      return options;
  }

  @Override
public String getOptions(String value)
  {
      StringBuffer htmlOptions = new StringBuffer();
//      Option nullOption = new Option("","");
//      htmlOptions.append(nullOption.getHtml(value));
      for (int i=0; this.options!=null && i<this.options.size(); i++)
      {
          Option option = (Option)options.get(i);
          htmlOptions.append(option.getHtml(value));
      }
      return htmlOptions.toString();
  } 
}


